main(List<String> args) {}

// 用dart官网一句话来概括: Mixins是一种可以在多个类层次结构中复用类代码的方式。
//mixins多继承模型实现
abstract class Vehicle {}

abstract class MotorVehicle extends Vehicle {}

abstract class NonMotorVehicle extends Vehicle {}

//将各自的能力抽成独立的Mixin类
// mixin PetrolDriven {//使用mixin关键字代替class声明一个Mixin类
//   void petrolDriven() => print("汽油驱动");
// }

mixin PassengerService {
  //使用mixin关键字代替class声明一个Mixin类
  void passengerService() => print('载人');
}

mixin CargoService {
  //使用mixin关键字代替class声明一个Mixin类
  void carryCargo() => print('载货');
}

mixin ElectricalDriven {
  //使用mixin关键字代替class声明一个Mixin类
  void electricalDriven() => print("电能驱动");
}

class PetrolDriven {
  factory PetrolDriven._() => null; //主要是禁止PetrolDriven被继承以及实例化
  void petrolDriven() => print("汽油驱动");
}

class Motor extends MotorVehicle
    with PetrolDriven, PassengerService, CargoService {} //利用with关键字使用mixin类

class Bus extends MotorVehicle
    with PetrolDriven, ElectricalDriven, PassengerService {} //利用with关键字使用mixin类

class Truck extends MotorVehicle with PetrolDriven, CargoService {
} //利用with关键字使用mixin类

class Bicycle extends NonMotorVehicle with ElectricalDriven, PassengerService {
} //利用with关键字使用mixin类

class Bike extends NonMotorVehicle with PassengerService {} //利用with关键字使用mixin类
